Skip to content

feat: add option to truncate GitHub annotations - #157

Open
Haadiyah-Zafar wants to merge 2 commits into
pytest-dev:mainfrom
Haadiyah-Zafar:codex/truncate-long-annotations
Open

feat: add option to truncate GitHub annotations#157
Haadiyah-Zafar wants to merge 2 commits into
pytest-dev:mainfrom
Haadiyah-Zafar:codex/truncate-long-annotations

Conversation

@Haadiyah-Zafar

Copy link
Copy Markdown

Adds --github-annotation-max-length to optionally truncate long GitHub Actions annotation messages.

The default remains 0, which preserves the current behavior and disables truncation.

This helps keep the GitHub Actions annotations view readable when failures contain very long assertion messages or tracebacks.

Tests added for:

  • truncation helper behavior
  • emitted error annotation truncation
  • rejecting negative max lengths

@Haadiyah-Zafar Haadiyah-Zafar changed the title Add option to truncate GitHub annotations feat: add option to truncate GitHub annotations Aug 18, 2026
@edgarrmondragon edgarrmondragon self-assigned this Aug 19, 2026
@github-actions github-actions Bot added feat and removed feat labels Aug 19, 2026
@edgarrmondragon

Copy link
Copy Markdown
Collaborator

Thanks for the PR @Haadiyah-Zafar! Wanna fix the failing tests?

@edgarrmondragon edgarrmondragon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plugin is already enabled by default in tests

Comment thread plugin_test.py
Comment on lines +440 to +444
result = pytester.runpytest_subprocess(
"-p",
"pytest_github_actions_annotate_failures.plugin",
"--github-annotation-max-length=-1",
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result = pytester.runpytest_subprocess(
"-p",
"pytest_github_actions_annotate_failures.plugin",
"--github-annotation-max-length=-1",
)
result = pytester.runpytest_subprocess("--github-annotation-max-length=-1")

Comment thread plugin_test.py
Comment on lines +422 to +426
result = pytester.runpytest_subprocess(
"-p",
"pytest_github_actions_annotate_failures.plugin",
"--github-annotation-max-length=80",
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result = pytester.runpytest_subprocess(
"-p",
"pytest_github_actions_annotate_failures.plugin",
"--github-annotation-max-length=80",
)
result = pytester.runpytest_subprocess("--github-annotation-max-length=80")

Comment thread plugin_test.py
)

PYTEST_VERSION = version.parse(pytest.__version__)
REPO_ROOT = Path(__file__).parent

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this for the new tests? Can we get rid of it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants